//
//  UIBarButtonItem+Extension.m

//
//  Created by apple on 14-7-3.
//  Copyright (c) 2014年 邓建. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+ (UIBarButtonItem *)itemWithBackIconImage:(NSString *)icon setBackTitle:(NSString *)titleStr target:(id)target action:(SEL)action

{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
    button.titleLabel.font=[UIFont systemFontOfSize:17];
    [button setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [button setTitle:titleStr forState:UIControlStateNormal];
    if (titleStr.length>0) {
         button.frame =CGRectMake(0, 0, 60, 30);
    }
    else
    {
        button.frame =CGRectMake(0,0,32 ,21);
    }
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}


@end
